
#ifndef _BSP_IO_H_
#define _BSP_IO_H_

#include "gd32w51x.h"


typedef uint32_t GP_T;
typedef uint16_t Pin_T;


#define BSP_IO_ToPort(port)	(GP_T)(unsigned int)(port)
#define BSP_IO_ToPin(pin)	(Pin_T)(unsigned int)(pin)

#define BSP_IO_Set(gp, pin, state)		\
do {	\
    if((state) != 0){GPIO_BOP(gp) = (uint32_t)(pin);}		\
	else{GPIO_BC(gp) = (uint32_t)(pin);}		\
}while(0)


#define BSP_IO_Get(gp, pin)			(GPIO_ISTAT(gp)&(pin) ? 1 : 0)

void BSP_IO_Init(GP_T gp, Pin_T pin, uint32_t mode);
void BSP_IO_SetMode(GP_T gp, Pin_T pin, uint32_t mode);
void BSP_IO_Active(GP_T gp);

#endif
